import { FC, memo, PropsWithChildren, useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const ScrollToTop: FC<PropsWithChildren<{}>> = ({ children }) => {
  const { pathname } = useLocation();

  useEffect(() => {
    window.scrollTo({ left: 0, top: 0, behavior: 'auto' });
  }, [pathname]);
  return <>{children}</>;
};

export default memo(ScrollToTop);
